package jmine.tec.utils.reflection.fast.asm;

import java.lang.reflect.Constructor;

import jmine.tec.utils.reflection.fast.FastConstructorImpl;

/**
 * @author takeshi
 */
public class AsmFastConstructor extends FastConstructorImpl {

    private final int index;

    private final GeneratedFastClassAccessor gen;

    /**
     * C'tor
     * 
     * @param ctor {@link Constructor}
     * @param index int
     * @param gen {@link GeneratedFastClassAccessor}
     */
    public AsmFastConstructor(Constructor<?> ctor, int index, GeneratedFastClassAccessor gen) {
        super(ctor);
        this.index = index;
        this.gen = gen;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object build(Object... args) throws Exception {
        return this.gen.invokeConstructor(this.index, args);
    }

}
